home *** CD-ROM | disk | FTP | other *** search
/ Java Primer Plus / Java Primer Plus (Waite Group Proess)(1996).iso / java_Win / demo / Fractal / CLSTurtle.class (.txt) < prev    next >
Encoding:
Java Class File  |  1995-10-12  |  1.5 KB  |  51 lines

  1. import java.awt.Graphics;
  2.  
  3. class CLSTurtle {
  4.    float angle;
  5.    // $FF: renamed from: X float
  6.    float field_0;
  7.    // $FF: renamed from: Y float
  8.    float field_1;
  9.    float scaleX;
  10.    float scaleY;
  11.    int xoff;
  12.    int yoff;
  13.  
  14.    public CLSTurtle(float ang, float x, float y, int xorg, int yorg, float sx, float sy) {
  15.       this.angle = ang;
  16.       this.scaleX = sx;
  17.       this.scaleY = sy;
  18.       this.field_0 = x * sx;
  19.       this.field_1 = y * sy;
  20.       this.xoff = xorg;
  21.       this.yoff = yorg;
  22.    }
  23.  
  24.    public CLSTurtle(CLSTurtle turtle) {
  25.       this.angle = turtle.angle;
  26.       this.field_0 = turtle.field_0;
  27.       this.field_1 = turtle.field_1;
  28.       this.scaleX = turtle.scaleX;
  29.       this.scaleY = turtle.scaleY;
  30.       this.xoff = turtle.xoff;
  31.       this.yoff = turtle.yoff;
  32.    }
  33.  
  34.    public void rotate(float theta) {
  35.       this.angle += theta;
  36.    }
  37.  
  38.    public void jump() {
  39.       this.field_0 += (float)Math.cos((double)this.angle) * this.scaleX;
  40.       this.field_1 += (float)Math.sin((double)this.angle) * this.scaleY;
  41.    }
  42.  
  43.    public void draw(Graphics g) {
  44.       float x = this.field_0 + (float)Math.cos((double)this.angle) * this.scaleX;
  45.       float y = this.field_1 + (float)Math.sin((double)this.angle) * this.scaleY;
  46.       g.drawLine((int)this.field_0 + this.xoff, (int)this.field_1 + this.yoff, (int)x + this.xoff, (int)y + this.yoff);
  47.       this.field_0 = x;
  48.       this.field_1 = y;
  49.    }
  50. }
  51.